package com.lagou.goods.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lagou.common.pojo.Goods;
import com.lagou.common.pojo.GoodsVo;
import com.lagou.goods.mapper.GoodsMapper;
import com.lagou.goods.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/goods")
public class GoodsController {

    @Autowired
    private GoodsService goodsService;


    @GetMapping("/query/{id}")
    public Goods queryById(@PathVariable Integer id){
        return goodsService.queryById(id);

    }

    @GetMapping("/delete/{id}")
    public int delete(@PathVariable Integer id){
        return goodsService.deleteById(id);
    }

    @RequestMapping("/update")
    @ResponseBody
    public int updateById(@RequestBody Goods goods){
        return goodsService.updateById(goods);
    }

    @GetMapping("/queryList")
    public GoodsVo queryList(Integer current,Integer size){
        System.out.println(current);
        System.out.println(size);
        return goodsService.queryList(current,size);


    }

}
